﻿using System;

namespace SharpDepend.Classes.Threading
{
    public class ThreadChecker
    {
        private int mThreadId;

        public ThreadChecker()
        {
            mThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
        }

        public void Check()
        {
            if (System.Threading.Thread.CurrentThread.ManagedThreadId != mThreadId)
            {
                throw new InvalidOperationException("Another thread was trying to access this state.");
            }
        }
    }
}
